package com.example.shysx11.vos;

import lombok.Data;

@Data
public class ResultVo<T> {
    private Integer code;
    private String message;
    private T t;

    public ResultVo() {}

    public ResultVo(Integer code, String message, T t) {
        this.code = code;
        this.message = message;
        this.t = t;
    }

    public ResultVo(Integer code, T t) {
        this.code = code;
        this.message = "成功";
        this.t = t;
    }

    public ResultVo(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    // 统一成功码（与前端约定：6001）
    public static <T> ResultVo<T> success(String message, T t) {
        return new ResultVo<>(6001, message, t);
    }

    public static <T> ResultVo<T> success(T t) {
        return new ResultVo<>(6001, "成功", t);
    }

    public static <T> ResultVo<T> success() {
        return new ResultVo<>(6001, "成功", null);
    }

    // 统一错误码（示例：7000，可扩展）
    public static <T> ResultVo<T> error() {
        return new ResultVo<>(7000, "操作失败");
    }

    public static <T> ResultVo<T> error(String message) {
        return new ResultVo<>(7000, message);
    }

    public static <T> ResultVo<T> error(Integer code, String message) {
        return new ResultVo<>(code, message);
    }
}